//
//  GBUrlWebViewController.m
//  PublicSentimentMonitorSystem
//
//  Created by 郭斌 on 15/8/25.
//  Copyright (c) 2015年 魏强. All rights reserved.
//

#import "GBUrlWebViewController.h"

@interface GBUrlWebViewController ()
{
     UIWebView *webview; //webview
}
@property (nonatomic, strong) UIButton *rightBarBtn;

@end

@implementation GBUrlWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, screenW, screenH - 49)];
//    NSLog(@"%@",_urlStr);
    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:_urlStr]];
    webview.scalesPageToFit = YES;
    webview.scrollView.bounces = NO;
    //设置滚动条的显示
    //水平滚动条
    webview.scrollView.showsHorizontalScrollIndicator = NO;
    //垂直滚动条
    webview.scrollView.showsVerticalScrollIndicator = NO;
    [webview loadRequest:request];
    [self.view addSubview:webview];
    [self setUpRightBarBtn];
    // Do any additional setup after loading the view.
}

/***  创建右边刷新按钮 */
- (void)setUpRightBarBtn
{
    UIButton *rightBarBtn = [[UIButton alloc]init];
    self.rightBarBtn = rightBarBtn;
    UIImage *image = [UIImage imageNamed:@"刷新"];
    rightBarBtn.width = image.size.width ;
    rightBarBtn.height = image.size.height;
    rightBarBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [rightBarBtn setImage:image forState:UIControlStateNormal];;
    [rightBarBtn addTarget:self action:@selector(rightBarBtnClick) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightBarBtn];
}
-(void)rightBarBtnClick
{
    
    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:_urlStr]];
    [webview loadRequest:request];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
